home *** CD-ROM | disk | FTP | other *** search
- package sub_arctic.lib;
- import sub_arctic.input.*;
- import sub_arctic.output.*;
-
- import java.awt.Point;
- import java.awt.Font;
-
- /*
- * This is a menu item which can pullright a submenu. It is derived
- * from a text menu item, so it shows a text label in its area.
- *
- * @author Ian Smith
- */
- public class pullright_menu_item extends text_menu_item {
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Value of the menu we are displaying
- */
- protected menu _pullright;
-
- /**
- * Return the value of the menu we are capable of pulling to the right.
- * @return menu the menu object that we pull right
- */
- public menu pullright() { return _pullright;};
-
- /**
- * Set the menu that we pull to the right.
- * @param menu p the new pull right menu
- */
- public void set_pullright(menu p) { _pullright=p;};
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Construct one of these pullright menu thingees.
- *
- * @param String t the string to display.
- * @param Font f the font to display the string in.
- * @param int width the width of the item.
- * @param menu m the menu to pull right.
- */
- public pullright_menu_item(String t, Font f,
- int width, menu m)
- {
-
- super(t,f,width);
- _pullright=m;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Construct one of these pullright menus with a default font.
- *
- * @param String t the string to display.
- * @param int width the width of the item.
- * @param menu m the menu to pull right.
- */
- public pullright_menu_item(String t, int width, menu m)
- {
-
- super(t,width);
- _pullright=m;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /*
- * Do the highlight behavior. This ends up popping up the menu.
- * @param event e the event that caused the highlight.
- */
- public void highlight(event e)
- {
-
- /* our upper left is the coordinate in question */
- Point p=new Point(0,0);
-
- /* superclass behavior */
- super.highlight(e);
-
- /* get the toplevel */
- top_level tl=get_top_level();
-
- /* convert to global space */
- p=local_to_global(p);
-
- /* now pop the menu up if we have one */
- if (pullright()!=null) {
-
- /* set the location of the menu */
- pullright().set_x(p.x+w());
- pullright().set_y(p.y);
-
- /* put it in the list of children for our topmost parent */
- tl.add_child(pullright());
- menu.agent().add_to_focus(pullright(),e,null); /* no user info for now */
- }
- }
-
- //had:
- //* @exception general PROPAGATED
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Do the unhighlight behavior. This ends up popping down the menu.
- * event e the event that caused the unhighlight
- *
- */
- public void unhighlight(event e)
- {
-
- /* do superclass behavior */
- super.unhighlight(e);
-
- /* for cleanliness, we remove the child menu from its parent */
- get_top_level().remove_child(pullright());
- }
-
- //had:
- //* @exception general PROPAGATED
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Return a debugging string
- * @return String the name of this class plus its location
- */
- public String toString() {
- return "pullright_menu_item: [" + x() + "," + y() + "]";
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /*
- * Compute the new images for this object. We override this
- * so we can get the little knicknack on the object for the
- * pullright.
- */
- protected void style_changed() {
- style cs=style_manager.current_style();
-
- _look=cs.menu_item_image(text(),font(),x_border(),y_border(),
- w(),h(),true);
- damage_self();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- }
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-